<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="jquery-1.9.1.js"></script>
<script type="text/javascript">
	$(document).ready(function(){
		$("#updateNoticeBtn").click(function(){
			//alert("test");
			$("#updateNoticeForm").submit();
		});
		$("#deleteNoticeFileBtn").click(function(){
			var no=$("#id").val();
			var deleteFile=$("#deleteFile").val();
			confirm("파일을 삭제하시겠습니까?"){
				$.ajax({
					type:"POST",
					url:"deleteFileForUpdate.do",
					data:"no="+no,
					dataType:"json"
				});
			}
			
			//alert(deleteFile);
			
		});
	});
</script>
</head>
<body>
<center>
<h1>공지사항 수정하기</h1>
<form action="updateNotice.do" id="updateNoticeForm" enctype="multipart/form-data">
<input type="hidden" value="${requestScope.nvo.no }" id="no" name="no">
<table>
<tr>
	<td>제목:</td><td><input type="text" value="${requestScope.nvo.title }" id="title" name="title"></td>
</tr>
<tr>
	<td>작성자:</td><td><input type="text" value="${requestScope.nvo.writer }" id="writer" name="writer"></td>
</tr>
<tr>
	<td colspan="2">
	<c:choose>
		<c:when test="${requestScope.nvo.savFileName!=null }">
		<input type="hidden" id="deleteFile" value="${requestScope.nvo.savFileName}">
		${requestScope.nvo.savFileName}					
		<input type="button" value="파일삭제" id="deleteNoticeFileBtn">
		</c:when>
		<c:otherwise>
		<input type="file" name="uploadFile" value="파일선택">
		</c:otherwise>
	</c:choose>
	</td>
</tr>
<tr>
	<td colspan="2"><textarea rows="20" cols="50" id="content" name="content">${requestScope.nvo.content }</textarea></td>
</tr>
<tr>
	<td colspan="2"><input type="button"  value="수정하기" id="updateNoticeBtn"></td>
</tr>
</table>
</form>
</center>
</body>
</html>